<?php
/*
 * mk script file created on 07-jul-2005
 * jaco_at_pixeldump_dot_org
 * grabbing fonts
 */

include("sample_utils.php");                             // provides some utils and using mk

$swfFN = "sample04.swf";                                 // we'll look into this file

$si = new MKSwfInspector($swfFN);                       // start working on
$fcTag = $si->find_firstTagID(FONT2);

$msg = "sorry, seems to be no font in this swf";

if($fcTag){
	
	$fcTD = $fcTag->get_tagData();                       // get font data
	$f = new MKFontContainer($fcTD);                    // create new mk font object
	$mkf = substr($fcTD, $fcTag->get_tagSL() + 2);       // get body data
	$fontName = $f->get_fontName();                      // gets font name
	
	$fontPath = SERVER_MKFONTS .$fontName .".mkf";
	$mko = fopen($fontPath, "wb");                       // save ...
	fwrite($mko, $mkf, strlen($mkf));                    // on file
	fclose($mko);                                        // done
	
	$msg = "<br />font " .$fontName;
	$msg .= " grabbed successful, please look into " .SERVER_MKFONTS ."<br />";
	if(!file_exists($fontPath)) $msg = "<br />problems grabbing fonts, sorry :(<br/>";
}

echo show_content($msg, basename(__FILE__));
?>
